
import HtmlToJson from '../../components/html-parse/js/html2json.js';

let timeout = null;
let app = getApp();
const util = {
  times: function (current) {
    // 获取当前时间
    let myDate = new Date();
    // 年
    let year = myDate.getFullYear();
    // 月
    let month =
      myDate.getMonth() + 1 < 10
        ? "0" + (myDate.getMonth() + 1)
        : myDate.getMonth() + 1;
    // 日
    let day = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate();
    // 时
    let hh = myDate.getHours()< 10 ? "0" + myDate.getHours() : myDate.getHours();
    // 分
    let mm = myDate.getMinutes()< 10 ? "0" + myDate.getMinutes() : myDate.getMinutes();
    // 秒
    let ss = myDate.getSeconds()< 10 ? "0" + myDate.getSeconds() : myDate.getSeconds();
    
    let dateVal = "";
    switch (current) {
      case "ym":
        dateVal = year + "-" + month;
        break;
      case "currentDate":
      case "ymd":
        dateVal = year + "-" + month + "-" + day;
        break;
      case "ymd_hds":
        dateVal =
          year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;
        break;
      case "year":
        dateVal = year;
        break;
      case "month":
        dateVal = month;
        break;
    }
    return dateVal;
  },
  
  urlHttpToHttps(url){
    return url.replace("http://","https://");
  },
  /**
   * 
   * @param {*} str 原字符串
   * @param {*} tarage 被替换的字符
   * @param {*} newStr 最终想要的字符
   */
  replaceAll(str,tarage,newStr){
    if(str){
      for (let index = 0; index < str.length; index++) {
        let item = str[index];
        if(item==tarage){
          str=str.replace(tarage,newStr);
          index = 0;
        }
      }
      return str;
    }
  },
  isPositiveInteger(value){
    let pattern = /^[1-9]\d*$/;
    return pattern.test(value);
  },
  isInteger(obj) {
    return obj%1 === 0
  },
  getNumberValue(num){
   // console.log("--原num:",num);
   let result="";
   if(this.isEmpty(num)){
    return result;
   }
   try {
    if(this.isInteger(num)){
      return num;
    }
    num=parseFloat(num);
    result=num.toFixed(2);
   } catch (error) {
    console.trace()
    console.log("--num:",num);
    console.log(error);
   }
   // console.log("--处理num:",result);
    return result;
  },
  getProjectAbbreviation(projectId,tapp){
    let ABBREVIATION="";
    try {
      let projectAllObj = dd.getStorageSync({ key: "$projectAllObj" }).data;
      if(this.isEmpty(tapp.prototype.$projectAllObj)&&this.isNotEmpty(projectAllObj) ){
        tapp.prototype.$projectAllObj = util.objectToMap(projectAllObj);
      }
      let json=tapp.prototype.$projectAllObj.get(projectId);
      if(this.isNotEmpty(json)){
        ABBREVIATION=json.ABBREVIATION;
      }
      
    } catch (error) {
      console.log(error);
    }
    
    return ABBREVIATION;
  },
  //区分 当前是否上班07:00-17:30  还是下班时间 除上班以外的时间
  getUpAndDownTime(testTime){
    let now=new Date();
    if(testTime){
      now=this.getDateByString(testTime);
    }
    let start_e="07:00:00";
    let end_e="17:30:00";
    let start_s=util.times("currentDate")+" "+start_e;
    let end_s=util.times("currentDate")+" "+end_e;
   // console.log(`--start_s:${start_s}----end_s:${end_s}`);
    let start_date=this.getDateByString(start_s);
    let end_date=this.getDateByString(end_s);
    let type_name="下班";
    if(now.getTime()>start_date.getTime()&&now.getTime()<end_date.getTime()){
      type_name="上班";
    }
  // console.log("---type_name:",type_name);
    return type_name;
  },
  paseStrTimeToDateFormat:function(str,format){
    let text="";
    switch (format) {
      case "ymd":
        let arr=str.split(" ");
        text=arr[0];
        break;
      default:
        break;
    }
    return text;
  },
  //时间戳转时长
  duration(timestamp){
    let time="",xh=0;
    let seconds = Math.floor(timestamp/1000);
    let day = Math.floor(seconds/3600/24);
    let hr = Math.floor((seconds/3600)%24);
    let min = Math.floor((seconds/60)%60);
    
    //天数换算小时
    if(util.isNotEmpty(day)){
      xh=Number(day)*24;
    }
    if(util.isNotEmpty(hr)){
      xh=Number(xh)+Number(hr);
    }
    if(xh!=0){
      time=xh+"小时";
    }

    if(xh==0){
      //未满一小时 分钟未满一分钟按小于1分钟算   ＜1分
      time+=min?min+"分钟":"1分钟";
    }else{
      //已满1小时，分钟未满1分钟 按0分钟计算
      time+=min?min+"分钟":"0分钟";
    }
    return time;
  },
  /**
   * @param {*} timestamp  两个时间差的 毫秒数
   * 2小时48分钟 ->2:48
   * 
   */
  durationSimp(timestamp){
    let time="",xh=0;
    let seconds = Math.floor(timestamp/1000);
    let day = Math.floor(seconds/3600/24);
    let hr = Math.floor((seconds/3600)%24);
    let min = Math.floor((seconds/60)%60);
    
    //天数换算小时
    if(util.isNotEmpty(day)){
      xh=Number(day)*24;
    }
    if(util.isNotEmpty(hr)){
      xh=Number(xh)+Number(hr);
    }
    if(xh<10){
      xh="0"+xh;
    }

    time+=xh;
    time+=":";

    // if(min){
    // }
    if(min<10){
      min="0"+min;
    }

    if(xh==0){
      //未满一小时 分钟未满一分钟按小于1分钟算   ＜1
      
      time+=min?min:"1";
    }else{
      //已满1小时，分钟未满1分钟 按0分钟计算
      time+=min?min:"0";
    }
    return time;
  },

  /**
   * 返回 日期字符
   * @param {*} date  日期类型
   * @param {*} format 要转换的日期格式
   */
  getStrDateFormat: function (date,format) {
    if(!date){
      return ""
    }
    
    // 获取当前时间
    let myDate = date;
    // 年
    let year = myDate.getFullYear();
    // 月
    let month =
      myDate.getMonth() + 1 < 10
        ? "0" + (myDate.getMonth() + 1)
        : myDate.getMonth() + 1;
    // 日
    let day = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate();
    // 时
    let hh = myDate.getHours()< 10 ? "0" + myDate.getHours() : myDate.getHours();
    // 分
    let mm = myDate.getMinutes()< 10 ? "0" + myDate.getMinutes() : myDate.getMinutes();
    // 秒
    let ss = myDate.getSeconds()< 10 ? "0" + myDate.getSeconds() : myDate.getSeconds();
    let dateVal = "";
    switch (format) {
      case "ym":
        dateVal = year + "-" + month;
        break;
      case "currentDate":
      case "ymd":
        dateVal = year + "-" + month + "-" + day;
        break;
      case "ymd_hds":
        dateVal =
          year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;
        break;
      case "ymd_hd":
        dateVal =
          year + "-" + month + "-" + day + " " + hh + ":" + mm ;
        break; 
      case "y2md.hd":
        let ye=(year+"").substring(2,4);
        dateVal =
        ye + "." + month + "." + day + " " + hh + ":" + mm ;
        break;   
      case "hd":
        dateVal =
           hh + ":" + mm ;
        break;  
      case "year":
        dateVal = year;
        break;
      case "month":
        dateVal = month;
        break;
    }
    return dateVal;
  },
  isTimeStr(str){
    let isTime=false;
    try{
      let timeValue=util.getDateByString(str);
      if(this.isNotEmpty(timeValue)){
        isTime=true
      }
    }catch(e){
      console.log(e);
    }
    return isTime;
  },
  strDateFormat: function (date,format) {
    // 获取当前时间
    let myDate = date;
    // 年
    let year = myDate.getFullYear();
    // 月
    let month =
      myDate.getMonth() + 1 < 10
        ? "0" + (myDate.getMonth() + 1)
        : myDate.getMonth() + 1;
    // 日
    let day = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate();
    // 时
    let hh = myDate.getHours()< 10 ? "0" + myDate.getHours() : myDate.getHours();
    // 分
    let mm = myDate.getMinutes()< 10 ? "0" + myDate.getMinutes() : myDate.getMinutes();
    // 秒
    let ss = myDate.getSeconds()< 10 ? "0" + myDate.getSeconds() : myDate.getSeconds();

    let dateVal = "";
    let rep_y="",rep_month="",rep_d="",rep_h="",rep_mm="",rep_s="";//需要替换的下标
    let arr= format.split(" ");
    try {
      for (let a=0;a<arr.length;a++){
        let item= arr[a];
        if(item.indexOf("-")!=-1){
          let arr2=item.split("-");
          for (let b=0;b<arr2.length;b++){
            if(!isNaN(arr2[b])){
              if(b==0){
                rep_y=arr2[b]
              }else if(b==1){
                rep_month=arr2[b]
              }else if(b==2){
                rep_d=arr2[b]
              }
            }
          }
        }else if(item.indexOf(":")!=-1){
          let arr2=item.split(":");
          for (let b=0;b<arr2.length;b++){
            if(!isNaN(arr2[b])){
              if(b==0){
                rep_h=arr2[b]
              }else if(b==1){
                rep_mm=arr2[b]
              }else if(b==2){
                rep_s=arr2[b]
              }
              
            }
          }
        }
      }
    } catch (error) {
      console.log(error);
    }
    dateVal =
    (rep_y?rep_y: year) + "-" + (rep_month?rep_month:month) + "-" + (rep_d?rep_d:day) + " " 
    + (rep_h?rep_h:hh) + ":" +(rep_mm?rep_mm: mm) + ":" + (rep_s?rep_s:ss);
    
    return dateVal;
  },
  /**
   * 计算相差时间 小时或分钟
   * @param {*} end  结束日期
   * @param {*} start  开始日期
   * @param {*} type day,hour,
   */
  getDateBetweenValue( end, start,type){
    let diff=0;
    if(!end||!start){
      return 0;
    }
    let days=end.getTime() -start.getTime();
    if(type=='day'){
      diff=parseInt(days/(1000*60*60*24));
    }
    if(type=='hour'){
      diff=parseInt(days/(1000*60*60));
    }
    return diff;
  },
  //获取昨天的日期
  getDateYesterday(date){
    return  new Date(date.getTime() - 24*60*60*1000);
  },
  // 在字符串第几位插入字符
  insertStrSeat(soure, start, newStr) {
    return soure.slice(0, start) + newStr + soure.slice(start);
  },
  copy(obj) {
    return JSON.parse(JSON.stringify(obj))
  },
  // a合并 b 返回a
  mergeObj(a,b){
    let result={...a,...b};
    return result;
  },
  // 在字符串前或后面插入字符
  insertStr(content, place, num, fillStr) {
    let str = "";
    if (place == "start") {
      str = content.padStart(num, fillStr);
    } else if (place == "end") {
      str = content.padEnd(num, fillStr);
    }
    return str;
  },
  // 判断数据类型
  isType(item) {
    let data = "";
    switch (Object.prototype.toString.call(item)) {
      case "[object Boolean]":
        data = "Boolean";
        break;
      case "[object Number]":
        data = "Number";
        break;
      case "[object String]":
        data = "String";
        break;
      case "[object Undefined]":
        data = "Undefined";
        break;
      case "[object Null]":
        data = "Null";
        break;
      case "[object Array]":
        data = "Array";
        break;
      case "[object Object]":
        data = "Object";
        break;
      case "[object Function]":
        data = "Function";
        break;
    }
    return data;
  },
  // 防抖
  debounce(fn, wait) {
    if (timeout !== null) clearTimeout(timeout);
    timeout = setTimeout(fn, wait);
  },
  //html字符串 转换为普通字符串
  htmlParseString(html) {
    let str = '';
    if (this.isNotEmpty(html)) {
      
      let transData = HtmlToJson.html2json(html, "myname");
      let arr = this.parseTransDataFn(transData);
      
      if (arr.length > 0) {
        if (arr.length > 1) {
          for (let index = 0; index < arr.length; index++) {
            const element = arr[index];
            let f="";
            if(element.name=="ol"){
              f="- ";
            }
            str +=f+ element.text + "\n"
          }
        } else {
          str = arr[0].text
        }
      }
    }
    return str;
  },
  changeNumMoneyToChese(n){
    var fraction = ['角', '分'];  
    var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];  
    var unit = [ ['元', '万', '亿'], ['', '拾', '佰', '仟']  ];  
    var head = n < 0? '欠': '';  
    n = Math.abs(n);  
 
    var s = '';  
 
    for (var i = 0; i < fraction.length; i++)   
    {  
        s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');  
    }  
    s = s || '整';  
    n = Math.floor(n);  
 
    for (var i = 0; i < unit[0].length && n > 0; i++)   
    {  
        var p = '';  
        for (var j = 0; j < unit[1].length && n > 0; j++)   
        {  
            p = digit[n % 10] + unit[1][j] + p;  
            n = Math.floor(n / 10);  
        }  
        s = p.replace(/(零.)*零$/, '').replace(/^$/, '零')  + unit[0][i] + s;  
    }  
    return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整'); 

  },
  //进一步提炼出 html字符串 得到的数组 转换为 简易数组
  parseTransDataFn(transData) {
    let arr = [];
    try {
      if (util.isNotEmpty(transData)) {
        //console.log("--transData:",transData);
        if(transData.nodes.length==1&&this.isEmpty(transData.nodes[0].nodes)){
          return arr;
        }
        for (let index = 0; index < transData.nodes.length; index++) {
          const element = transData.nodes[index];
          if(this.isEmpty(element.nodes)){
            continue;
          }
          this.forEachNodes(element,arr,element);
        }
      }
    } catch (error) {
      console.log(error);
    }

    return arr;
  },
  forEachNodes(node,arr,pnode){
    if(this.isNotEmpty(node.nodes)){

      for (let index = 0; index < node.nodes.length; index++) {
        let element = node.nodes[index];
        this.forEachNodes(element,arr,pnode);
      }
    }else if(this.isNotEmpty(node.text)){
      let json = {};
      json.name = pnode.tag;//nodes
      let type = node.node;//'text'
      let text = node.text;//内容
      json.type = type;
      json.text = text;
      arr.push(json);
    }
  },
  getStringYMDhmsByDate(date) { //日期转时间 yyyy-MM-dd hh:mm:ss
    let fmt = "yyyy-MM-dd hh:mm:ss";
    var o = {
      "M+": date.getMonth() + 1,                 //月份   
      "d+": date.getDate(),                    //日   
      "h+": date.getHours(),                   //小时   
      "m+": date.getMinutes(),                 //分   
      "s+": date.getSeconds(),                 //秒   
      "q+": Math.floor((date.getMonth() + 3) / 3), //季度   
      "S": date.getMilliseconds()             //毫秒   
    };
    if (/(y+)/.test(fmt))
      fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
      if (new RegExp("(" + k + ")").test(fmt))
        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
  },
  getStringYMDByDate(date) { //日期转时间字符串 yyyy-MM-dd
    let fmt = "yyyy-MM-dd";
    var o = {
      "M+": date.getMonth() + 1,                 //月份   
      "d+": date.getDate(),                    //日   
      "h+": date.getHours(),                   //小时   
      "m+": date.getMinutes(),                 //分   
      "s+": date.getSeconds(),                 //秒   
      "q+": Math.floor((date.getMonth() + 3) / 3), //季度   
      "S": date.getMilliseconds()             //毫秒   
    };
    if (/(y+)/.test(fmt))
      fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
      if (new RegExp("(" + k + ")").test(fmt))
        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
  },
  getCNStringYMDByDate(str){ //2023-03-28 ->2023年03月28日
    try {
      let arr=str.split("-");
      return arr[0]+"年"+arr[1]+"月"+arr[2]+"日"
    } catch (error) {
      console.log(error);
    }
    
  },
  getCreateBySample(str){
    let arr=str.split(" ");
    let arr_list= arr[0].split(" ")[0];
    let t=arr_list.split("-");
    let result=t[0]+t[1]+t[2]
   return result;
  },
  getDateByString(str) {//字符串转date类型
    try {
      let reg = /^(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/;
      if(str.indexOf("/")){
      //  reg = /^(\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/;
      }
      let s = str.match(reg);
      let result = "";
      if (s) {
        result = new Date(s[1], s[2] - 1, s[3], s[4], s[5], s[6]);
      }
      return result;
    } catch (error) {
      console.log(error);
      return "";
    }

  },
  smpleDateStrParseDateStr(dateStr){//230206转换为 2023-02-06
   let node1= dateStr.slice(0,2);
   let node2= dateStr.slice(2,4);
   let node3= dateStr.slice(4,6);
   let result="20"+node1+"-"+node2+"-"+node3;
   return result;
  },  
  dateStrParseSmpleStr(dateStr){//2023-02-06转换为230206
    if(this.isEmpty(dateStr)){
      return "";
    }
    if(dateStr.indexOf("-")!=-1){
      let new_str=dateStr.slice(2,dateStr.length);
      let str=new_str.split("-").join("");
      return str;
    }else{
      return dateStr;
    }
    
  },
  dateTimeStrParseSmpleStr(dateStr){//2023-02-06 14:01:11转换为230206140111
    if(this.isEmpty(dateStr)){
      return "";
    }
    let str="";
    if(dateStr.indexOf("-")!=-1){
      // let new_str=dateStr.slice(2,dateStr.length);
      // str=new_str.split("-").join("");
      // return str;
      let arr=dateStr.split(" ");
      let start=arr[0].slice(2,arr[0].length);
      start=start.split("-").join("");
      let end=arr[1].split(":").join("");
      str=start+end;
      return str;
    }else{
      return dateStr;
    }
    
  },
  dateRangeStrParseSmpleStr(dateStr){//2023-01-31 - 2023-02-03转换为230131-230203
    if(this.isEmpty(dateStr)){
      return "";
    }
    try{
      let str="";
      if(dateStr.indexOf(":")!=-1){
        let arr= dateStr.split("-");
         str= this.dateStrParseSmpleStr(arr[0])+"-"+this.dateStrParseSmpleStr(arr[1]);
        
      }else{
        str=dateStr
      }
      return str;
      
    }catch(e){
      console.log(e);
      return dateStr;
    }
    
  },
  // 比较当前日期是否比 目标日期大
  //currentDate>targetDate return true;currentDate<targetDate return false;
  compareDate(currentDate,targetDate){
     return currentDate>targetDate;
  },
  uuid() {
    var s = [];
    var hexDigits = "0123456789abcdef";
    for (var i = 0; i < 36; i++) {
      s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
    s[8] = s[13] = s[18] = s[23] = "-";

    var uuid = s.join("");
    return uuid;
  },
  isNotEmpty(str) {
    // 判断是否不为空

    // if (str === undefined || str === null || str === "" || str === "null") {
    //   return false;
    // } else if (str instanceof Array && str.length > 0) {
    //   return true;
    // } else if (str instanceof Object && JSON.stringify(str) == "{}") {
    //   return false;
    // } else {
    //   return true;
    // }
    return !this.isEmpty(str);
  },
  isEmpty(str) {
    // 判断是否为空
    let result=false;
    if (str === null || str === undefined || str === "" || str === "null") {
      result=true;
    } else if (str instanceof Array && str.length == 0) {
      result=true;
    } else if (str instanceof Object && JSON.stringify(str) == "{}") {
      result=true;
    } else {
      result=false;
    }
    return result;
  },
  // 保留两位小数点
  keepTwoDecimal(num) {
    var result = parseFloat(num);
    if (isNaN(result)) {
      return false;
    }
    result = Math.round(num * 100) / 100;
    return result;
  },
  message(message, time = 1000, type = 'none') {
    dd.showToast({
      content: message,
      type: type,
      duration: time,
    });
  },
  messageSuccess(message = "操作成功", fn) {
    dd.showToast({
      content: message,
      type: "success",
      duration: 1000,
      success: fn,
    });
  },
  fromEntries(iterable) {
    return [...iterable].reduce((obj, [key, val]) => {
      obj[key] = val;
      return obj;
    }, {});
  },
  mapToObject(map) {

    return this.fromEntries(map.entries());
  },
  objectToMap(obj) {
    let map;
    if (util.isNotEmpty(obj)) {
      map = new Map(Object.entries(obj))
    } else {
      map = new Map()
    }
    return map;
  },
  getUserMessage() { // 用户信息
    //console.log(app.prototype);
    dd.getStorage({
      key: "userMessage",
      success: res => {
        try {
          let data = res.data;
          if (this.isNotEmpty(data)) {
            app.prototype.$Token = data.token;
            app.prototype.$userName = data.userName;
            app.prototype.$userId = data.userId;
          }

        } catch (error) {
          console.log(error);
        }
      },
      fail: error => {
        dd.showToast({
          content: '自动登录已过期',
          type: 'fail',
          duration: 3000,
        });
        dd.redirectTo({ url: "../login/login" });
        // uni.reLaunch({url: "/pages/Login/Login"});
      }
    });
  },

  isOrderNum(type){
    let text="";
    switch (type+"") {
      case "1":
        //一般(这个用不到，是电脑端提起的，小程序只有2/3)
        text="Y";
        break;
      case "2":
        // 零星
        text="L";
        break;
      case "3":
        // 应急
        text="J";
        break;        
    }
    return text;
  },
  /*
  view: purchase , price , pact , payment
  APPROVAL_TYPE :页面详情接口来的 res.data.APPROVAL_TYPE
  */
  getDetailApprovalTypeApi(view, APPROVAL_TYPE) {
    if (util.isEmpty(APPROVAL_TYPE)) {
      this.message("APPROVAL_TYPE不能为空!")
      return false;
    }
    let type_name = this.getDetailApprovalTypeName(APPROVAL_TYPE);
    
    let approvalApi = this.approvalApiGain(view, type_name).approvalApi;
    approvalApi.text= this.approvalApiGain(view, type_name).text;
    return approvalApi;
  },
  getDetailApprovalTypeName(APPROVAL_TYPE) {
    let type_name = "";// Examination  examination
    if (APPROVAL_TYPE.indexOf("xamination") != -1) {
      type_name = "examination";
    } else if (APPROVAL_TYPE.indexOf("G2E") != -1) {
      type_name = "compoundG2E";
    } else if (APPROVAL_TYPE.indexOf("E2G") != -1) {
      type_name = "compoundE2G";
    } else {
      type_name = "gradually";
    }
    return type_name;
  },
  //提起审批，审批通过，审批退回，审批详情接口
  approvalApiGain(type, approvalType) {
    let text = "", approvalApi = {};
    switch (approvalType) {
      case "examination":
        text = "会同审批";
        approvalApi = this.approvalExamination(type)
        break;
      case "gradually":
        text = "依次审批";
        approvalApi = this.approvalGradually(type)
        break;
      case "compoundG2E":
        text = "依次转会同审批";
        approvalApi = this.approvalCompoundG2E(type)
        break;
      case "compoundE2G":
        text = "会同转依次审批";
        approvalApi = this.approvalCompoundE2G(type)
        break;
    }
    let json = { text, approvalApi };
    return json;
  },
  //各个页面的会同审批
  approvalExamination(type) {
    let approvalApi = {};
    switch (type) {
      case "purchase":
        //提起审批
        approvalApi.apiApprovalAddUrl = "/YhERP/ApprovalRule/purchase/JointExaminationSave";
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/purchase/JointExaminationEdit";

        //管理员 全部通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/purchaseJointExamination/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/purchaseJointExamination/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/purchaseJointExamination/back";
        break;
      case "price":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PriceCompare/JointExaminationEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PriceCompareJointExamination/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PriceCompareJointExamination/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PriceCompareJointExamination/back";

        break;
      case "pact":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PurchaseContract/JointExaminationEdit";

        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PurchaseContract/JointExaminationPass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PurchaseContractJointExamination/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PurchaseContract/JointExamination/back";

        break;
      case "payment":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PurchasePayment/JointExaminationEdit";

        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PurchasePaymentJointExamination/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PurchasePaymentJointExamination/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PurchasePaymentJointExamination/back";

        break;
      case "CalculationPayment":  
        //提起审批
        approvalApi.apiApprovalAddUrl = "/YhERP/ApprovalRule/CalculationPayment/JointExaminationSave";
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/CalculationPayment/JointExaminationEdit";

        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/CalculationPaymentJointExamination/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/CalculationPaymentJointExamination/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/CalculationPaymentJointExamination/back";

        break;
    }
    return approvalApi;

  },

  //各个页面的依次审批
  approvalGradually(type) {
    let approvalApi = {};
    switch (type) {
      case "purchase":
        //提起审批
        approvalApi.apiApprovalAddUrl = "/YhERP/ApprovalRule/purchase/save";
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/purchase/edit";

        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/purchase/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/purchase/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/purchase/back";
        break;
      case "price":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PriceCompare/edit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PriceCompare/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PriceCompare/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PriceCompare/back";

        break;
      case "pact":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PurchaseContract/edit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PurchaseContract/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PurchaseContract/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PurchaseContract/back";

        break;
      case "payment":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PurchasePayment/edit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PurchasePayment/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PurchasePayment/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PurchasePayment/back";

        break;

     case "CalculationPayment":  
        //提起审批
        approvalApi.apiApprovalAddUrl = "/YhERP/ApprovalRule/CalculationPayment/save";
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/CalculationPayment/edit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/CalculationPayment/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/CalculationPayment/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/CalculationPayment/back";
        break;  
    }
    return approvalApi;
  },

  //各个页面的依次转会同
  approvalCompoundG2E(type) {
    let approvalApi = {};
    switch (type) {
      case "purchase":
        //提起审批
        approvalApi.apiApprovalAddUrl = "/YhERP/ApprovalRule/purchase/CompoundG2ESave";
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/purchase/CompoundG2EEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/purchaseCompoundG2E/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/purchaseCompoundG2E/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/purchaseCompoundG2E/back";
        break;
      case "price":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PriceCompare/CompoundG2EEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PriceCompareCompoundG2E/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PriceCompareCompoundG2E/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PriceCompareCompoundG2E/back";

        break;
      case "pact":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PurchaseContract/CompoundG2EEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PurchaseContractCompoundG2E/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PurchaseContractCompoundG2E/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PurchaseContractCompoundG2E/back";

        break;
      case "payment":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PurchasePaymentCompound/CompoundG2EEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PurchasePaymentCompoundG2E/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PurchasePaymentCompoundG2E/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PurchasePaymentCompoundG2E/back";

        break;
      case "CalculationPayment":  
        //提起审批
        approvalApi.apiApprovalAddUrl = "/YhERP/ApprovalRule/CalculationPayment/CompoundG2ESave";
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/CalculationPayment/CompoundG2EEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/CalculationPaymentCompoundG2E/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/CalculationPaymentCompoundG2E/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/CalculationPaymentCompoundG2E/back";
        break;  

    }
    return approvalApi;

  },
  //各个页面的会同转依次
  approvalCompoundE2G(type) {
    let approvalApi = {};
    switch (type) {
      case "purchase":
        //提起审批
        approvalApi.apiApprovalAddUrl = "/YhERP/ApprovalRule/purchase/CompoundE2GSave";
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/purchase/CompoundE2GEdit";

        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/purchaseCompoundE2G/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/purchaseCompoundE2G/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/purchaseCompoundE2G/back";
        break;
      case "price":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PriceCompare/CompoundE2GEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PriceCompareCompoundE2G/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PriceCompareCompoundE2G/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PriceCompareCompoundE2G/back";

        break;
      case "pact":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PurchaseContract/CompoundE2GEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PurchaseContractCompoundE2G/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PurchaseContractCompoundE2G/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PurchaseContractCompoundE2G/back";

        break;
      case "payment":
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/PurchasePayment/CompoundE2GEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/PurchasePaymentCompoundE2G/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/PurchasePaymentCompoundE2G/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/PurchasePaymentCompoundE2G/back";
        break;
      case "CalculationPayment":  
        //提起审批
        approvalApi.apiApprovalAddUrl = "/YhERP/ApprovalRule/CalculationPayment/CompoundE2GSave";
        //部分通过 个人通过 拒绝
        approvalApi.apiApprovalSubmitUrl = "/YhERP/ApprovalRule/CalculationPayment/CompoundE2GEdit";
        //管理员通过 接口
        approvalApi.apiApprovalAdminSubmitUrl = "/YhERP/ApprovalRule/CalculationPaymentCompoundE2G/pass";
        //审批详情
        approvalApi.apiApprovalOpenUrl = "/YhERP/ApprovalRule/CalculationPaymentCompoundE2G/views";
        //撤回
        approvalApi.apiApprovalWithdrawUrl = "/YhERP/ApprovalRule/CalculationPaymentCompoundE2G/back";
        break;        
    }
    return approvalApi;

  }
}
export default util;